package com.my.objects;

import java.io.Serial;
import java.io.Serializable;

/**
 * @description:
 * @author: marshal
 * @date: 2021-08-24 2:28 PM
 * 当程序序列化一个Teacher对象时，如果该Teacher对象持有一个Person对象的引用，为了在反序列化时可以正常恢复该Teacher对象，程序会顺带将该Person对象也进行序列化，所以Person类也必须是可序列化的，否则Teacher类将不可序列化。
 *
 */
public class Teacher implements Serializable {
    @Serial
    private static final long serialVersionUID = 921241542248785396L;

    private String name;
    private Person student;

    public Teacher(String name, Person student) {
        this.name = name;
        this.student = student;
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "name='" + name + '\'' +
                ", student=" + student +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Person getStudent() {
        return student;
    }

    public void setStudent(Person student) {
        this.student = student;
    }
}
